package offerv1;

public class Offer53_2 {

    public int missingNumber(int[] nums) {
        int n = nums.length, left = 0, right = n - 1;
        while (left <= right) {
            int mid = (right - left) / 2 + left;
            if (nums[mid] == mid) {
                left = mid + 1;
            } else if (nums[mid] != mid) {
                right = mid - 1;
            }
        }
        return right + 1;
    }
}
